import os

from dotenv import load_dotenv
from pyrogram import Client
from apscheduler.schedulers.asyncio import AsyncIOScheduler


# Подгружаем файл .env и его содержимое
dotenv_path = os.path.abspath(
    os.path.join(os.path.dirname( __file__ ), '..', '.env')
)
if os.path.exists(dotenv_path): load_dotenv(dotenv_path)
else: raise Exception('Не найден файл .env')

TOKEN_TELEGRAM_BOT: str = os.getenv('TOKEN_TELEGRAM_BOT')
NAME_TELEGRAM_BOT: str = os.getenv('NAME_TELEGRAM_BOT')
API_ID_TELEGRAM_APP: str = os.getenv('API_ID_TELEGRAM_APP')
API_HASH_TELEGRAM_APP: str = os.getenv('API_HASH_TELEGRAM_APP')
TELEGRAM_BOT_ADMIN_ID: int = int(os.getenv('TELEGRAM_BOT_ADMIN_ID'))

BOT_SESSION_PATH: str = os.getcwd() + f'/{NAME_TELEGRAM_BOT}.session'
PATH_TO_WORKDIR: str = os.path.abspath(
    os.path.join(os.path.dirname(__file__ ), '..', 'db')
)
PATH_TO_DATABASE: str = os.path.abspath(
    os.path.join(os.path.dirname(__file__ ), '..', 'db/db.json')
)

pyrogram_app: Client = Client(
    name=NAME_TELEGRAM_BOT,
    api_id=API_ID_TELEGRAM_APP,
    api_hash=API_HASH_TELEGRAM_APP,
    bot_token=TOKEN_TELEGRAM_BOT,
    workdir=PATH_TO_WORKDIR
)
scheduler = AsyncIOScheduler()
